const KEY_ACCESS_TOKEN = 'ACCESS_TOKEN';
const system = uni.getSystemInfoSync();// 获取系统信息
var noClick=true;
function _message(message, icon, settings) {
	let options = {
		title: message
	};
	if (icon) options.icon = icon;
	if (settings) object.assign(options, settings);
	uni.showToast(options);
}
export default {
	randomNum(minNum,maxNum){
		switch(arguments.length){
		    case 1: 
		        return parseInt(Math.random()*minNum+1,10); 
		    break; 
		    case 2: 
		        return parseInt(Math.random()*(maxNum-minNum+1)+minNum,10); 
		    break; 
		        default: 
		            return 0; 
		        break; 
		} 
	},
	hasLogin() {
		return !!this.getAuthCode();
	},
	getAuthCode: function() {
		return uni.getStorageSync(KEY_ACCESS_TOKEN);
	},
	setAuthCode: function($authcode) {
		uni.setStorageSync(KEY_ACCESS_TOKEN, $authcode);
	},
	goHome: function() {
		uni.switchTab({
			url: '/pages/tabbr/home'
		})
	},
	WinxinAuthorize: function() {
		uni.showModal({
			title: '温馨提示',
			content: '您还未登录，是否前往登录',
			success: function(res) {
				if (res.confirm) {
					uni.navigateTo({
						// url: '/login/home/booking/authorize-login/authorize-login?url="/pages/tabBar/user"',
						url: '/login/views/authorize-login?url="/pages/tabbr/user"'
					})
				}
			}
		});
	},

	showLoading: function(message) {
		if (wx.showLoading) {
			// 基础库 1.1.0 微信6.5.6版本开始支持，低版本需做兼容处理
			wx.showLoading({
				title: message,
				mask: true
			});
		} else {
			// 低版本采用Toast兼容处理并将时间设为20秒以免自动消失
			wx.showToast({
				title: message,
				icon: 'loading',
				mask: true,
				duration: 20000
			});
		}
	},

	hideLoading: function() {
		if (wx.hideLoading) {
			// 基础库 1.1.0 微信6.5.6版本开始支持，低版本需做兼容处理
			wx.hideLoading();
		} else {
			wx.hideToast();
		}
	},
	getDate: function(date, AddDayCount = 0) {
		if (typeof date !== 'object') {
			date = date.replace(/-/g, '/');
		}
		let dd = new Date(date);
		dd.setDate(dd.getDate() + AddDayCount); // 获取AddDayCount天后的日期
		let y = dd.getFullYear();
		let m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1; // 获取当前月份的日期，不足10补0
		let d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate(); // 获取当前几号，不足10补0
		return y + '/' + m + '/' + d;

	},
	
	formatAmount :function (number, fractionDigits)  {
	  // 默认值处理和超出范围处理
	  fractionDigits = fractionDigits === undefined ? 2 : fractionDigits < 0 || fractionDigits > 20 ? 0 : fractionDigits;
	  // 四舍五入
	  number = Math.round(number * Math.pow(10, fractionDigits)) / Math.pow(10, fractionDigits);
	  // 取小数位
	  return Number(number.toFixed(fractionDigits));
	},
	///时间格式转化方法
	TimeFormat(time,intercept=false){
		if(time){
			if(time.indexOf('-')>0){
				var date=intercept?new Date(time.replace(/-/g,'/')).Format("yyyy.MM.dd"):new Date(time.replace(/-/g,'/')).Format("yyyy.MM.dd hh:mm:ss");
				return date;
			}else{
				var date=intercept?new Date(time).Format("yyyy.MM.dd"): new Date(time).Format("yyyy.MM.dd hh:mm:ss");
				return date;
			}
		}
	},
	formatNum: function(f, digit) {
		f = Math.round(f * Math.pow(10, digit)) / Math.pow(10, digit);
		// 取小数位
		return Number(f.toFixed(digit));
	},
	html: function(html) {
		html = html.replace(/<img /g, '<img style="max-width:100%;height:auto;"');
		html = html.replace(/&hellip;/g, '');
		return html;
	},
	set(key, value) {
		uni.setStorageSync(key, JSON.stringify(value));
	},
	get(key) {
		return JSON.parse(uni.getStorageSync(key) || 'null') || null;
	},
	remove(key) {
		return new Promise(function(resolve, reject) {
			return uni.removeStorageSync(key), resolve();
		});
	},
	clone(data) {
		return JSON.parse(JSON.stringify(data));
	},
	msg: {
		message: _message,
		info(message) {
			_message(message);
		},
		error(message) {
			_message(message, 'none'); //'/static/cuo.png'
		},
		success(message) {
			_message(message, 'success');
		},
		confirm(message) {
			return new Promise(function(resolve, reject) {
				uni.showModal({
					title: '温馨提示',
					content: message,
					success: function(res) {
						if (res.confirm) {
							resolve(res);
						} else if (res.cancel) {
							reject(res);
						}
					}
				});
			});
		}
	},
	getCountDown(startTime, endTime) {
		const diff = endTime.getTime() - startTime.getTime();
		// console.log(diff)
		var days = Math.floor(diff / (24 * 3600 * 1000))

		//计算出小时数
		const leave1 = diff % (24 * 3600 * 1000) //计算天数后剩余的毫秒数
		const hours = Math.floor(leave1 / (3600 * 1000))
		//计算相差分钟数
		const leave2 = leave1 % (3600 * 1000) //计算小时数后剩余的毫秒数
		const minutes = Math.floor(leave2 / (60 * 1000))
		//计算相差秒数
		const leave3 = leave2 % (60 * 1000) //计算分钟数后剩余的毫秒数
		const seconds = Math.round(leave3 / 1000)
		// alert(" 相差 "+days+"天 "+hours+"小时 "+minutes+" 分钟"+seconds+" 秒");

		let raw = '';
		if (days >= 0) raw += `${days}天`;
		if (hours >= 0) raw += `${hours}小时`;
		if (minutes >= 0) raw += `${minutes}分钟`;
		if (seconds >= 0) raw += `${seconds}秒`;
		return raw;
	},
	navigateToBack(delta) {
		uni.navigateBack({
			delta: delta || 1
		});
	},
	showLoading() {
		var message = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "加载中";
		uni.showLoading({
			title: message,
			mask: true
		});
	},
	hideLoading() {
		uni.hideLoading();
	},
	setTitle(title) {
		uni.setNavigationBarTitle({
			title: title
		});
	},
	truncate(str, maxLength) {
		maxLength = maxLength || 38;
		return str.length > maxLength ? `${str.slice(0, maxLength)}...` : str;
	},
	getQueryStringByName(name) {
		var result = location.search.match(new RegExp("[\?\&]" + name + "=([^\&]+)", "i"));
		if (result == null || result.length < 1) {
			return "";
		}
		return result[1];
	},
	createUUID(len = 32, firstU = true, radix = null) {
		let chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
		let uuid = [];
		radix = radix || chars.length;

		if (len) {
			// 如果指定uuid长度,只是取随机的字符,0|x为位运算,能去掉x的小数位,返回整数位
			for (let i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
		} else {
			let r;
			// rfc4122标准要求返回的uuid中,某些位为固定的字符
			uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
			uuid[14] = '4';

			for (let i = 0; i < 36; i++) {
				if (!uuid[i]) {
					r = 0 | Math.random() * 16;
					uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
				}
			}
		}
		// 移除第一个字符,并用u替代,因为第一个字符为数值时,该guuid不能用作id或者class
		if (firstU) {
			uuid.shift();
			return 'u' + uuid.join('');
		} else {
			return uuid.join('');
		}
	},
	/**判断Android和ios的GPS是否打开*小程序授权*/
	checkOpenGPSServiceByAndroidAndIos() {
		// #ifdef APP-PLUS
		let system = uni.getSystemInfoSync();// 获取系统信息
		if (system.platform === 'android') { // 判断平台
		    var context = plus.android.importClass("android.content.Context");
		    var locationManager = plus.android.importClass("android.location.LocationManager");
		    var main = plus.android.runtimeMainActivity();
		    var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
		    if (!mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)) {
		      uni.showModal({
		        title: '提示',
		        content: '请先打开GPS定位',
		        cancelText:"取消",
				confirmText:"去设置",
		        success(res) {
					if(res.confirm){
						if (!mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)) {
						  var Intent = plus.android.importClass('android.content.Intent');
						  var Settings = plus.android.importClass('android.provider.Settings');
						  var intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); 
						  main.startActivity(intent); // 打开系统设置GPS服务页面
						} else {
						  console.log('GPS功能已开启');
						}
					}else{
						console.log("打开GPS失败")
					}
					
		          
		        }
		      });
		    }
		}else{
			let cllocationManger = plus.ios.importClass("CLLocationManager");    
			let enable = cllocationManger.locationServicesEnabled();    
			let status = cllocationManger.authorizationStatus();      
			if (enable && status != 2) {    
			} else {   
				//  定位没有开启时  提示用户是否开启  
				plus.nativeUI.confirm("定位权限没有开启，是否去开启？", function(e) {    
					if (e.index == 0) {    
						let UIApplication = plus.ios.importClass("UIApplication");    
						let application2 = UIApplication.sharedApplication();    
						let NSURL2 = plus.ios.importClass("NSURL");                          
						let setting2 = NSURL2.URLWithString("app-settings:"); // 打开应用权限  
						application2.openURL(setting2);    
						plus.ios.deleteObject(setting2);    
						plus.ios.deleteObject(NSURL2);    
						plus.ios.deleteObject(application2);    
					}    
				}, {    
					"buttons": ["不开启", "去设置"],    
					"verticalAlign": "center"    
				});    
			}    
			plus.ios.deleteObject(cllocationManger);   
		}
		// #endif
		
		// #ifdef MP-WEIXIN
			uni.getSetting({
				success(res) {
					//console.log(res)
					if (res.authSetting['scope.userLocation']) {
						console.log("userLocation位置功能已授权")
						// 如果已授权,直接获取对应参数
						uni.getLocation({
							success(res) {
								console.log(res)
								
							}
						})
					} else if (!res.authSetting['scope.userLocation']) {
						// 说明此时要获取的位置功能尚未授权,
						// 则设置进入页面时主动弹出，直接授权
						uni.authorize({
							scope: 'scope.userLocation',
							success(res) {
								// 授权成功
								console.log(res)
								// 成功后获取对应的位置参数
								uni.getLocation({
									success(res) {
										console.log(res)
										
									}
								})
							},
							fail() {
								console.log("位置授权失败")
								uni.showModal({
									title:"温馨提示",
									content:'检测到您没打开获取信息功能权限，是否去设置打开？',
									confirmText: "确认",
									cancelText:'取消',
									success: (res) => {
										console.log(res)
										if(res.confirm){
											uni.openSetting({
												success: (res) => {
													console.log(res);
												},
												fail: (err) => {
													console.log(err)
												}
											})
										}else{
											console.log('取消');
										}
									}
								})
							}
						})
					}
				},
				fail() {
					console.log("获取授权信息授权失败")
				}
			})
		// #endif
	},
	
	/**扫码
	 **自定义状态码{ code=0 (取消扫码) code=1 (正常扫码成功) code=''||其他 其他问题 }
	 * 
	**/
	scan(callback){
		// #ifdef APP-PLUS || MP-WEIXIN
		uni.scanCode({
			success: (res) => {
				res.code=1
				var a = res.result;
				return callback(res)
			},
			fail: (err) => {
				if(err.errMsg=='scanCode:fail cancel'){
					err.code=0
					return callback(err)
				}else{
					uni.getSetting({
						success: (res) => {
							let authStatus = res.authSetting['scope.camera'];
							if (!authStatus) {
								uni.showModal({
									title: '授权失败',
									content: '需要使用您的相机，请在设置界面打开相关权限',
									success: (res) => {
										if (res.confirm) {
											uni.openSetting()
										}
									}
								})
							}
						}
					})
				}
			
			}
		});
		// #endif
		
		// #ifdef H5
		uni.showToast({
			title:"请在手机端打开",
			icon:"none"
		})
		// #endif
	},
	getDate(starts,ends){
		let timeobj={},msg=''
		let begDate = new Date(starts);
		let endDate = new Date(ends);
		let end = endDate.getTime(); // 结束秒数
		let beg = begDate.getTime(); // 开始秒数
	
		let timeFunction = () => {
		  let date = new Date();
		  let now = date.getTime();
		  let leftTime = end - now;
		  let begTime = beg - now;
		  if (begTime >= 0) {
			msg = '距开始';
			timeobj = {
			  days: Math.floor(begTime / 1000 / 60 / 60 / 24),
			  hours: Math.floor(begTime / 1000 / 60 / 60 % 24),
			  minutes: Math.floor(begTime / 1000 / 60 % 60),
			  seconds: Math.floor(begTime / 1000 % 60)
			};
			//return timeobj
		  } else if (leftTime >= 0) {
			msg = '距结束';
			timeobj = {
			  days: Math.floor(leftTime / 1000 / 60 / 60 / 24),
			  hours: Math.floor(leftTime / 1000 / 60 / 60 % 24),
			  minutes: Math.floor(leftTime / 1000 / 60 % 60),
			  seconds: Math.floor(leftTime / 1000 % 60)
			};
			
			
			//return timeobj
		  } else {
			msg = "已结束";
			clearInterval(go);
		  }
		  
		};
		
		timeFunction();
		
		let go = setInterval(function () {
			timeFunction();
			
		}, 1000);
	},
	isOpenLoctionServer(){
		if (system.platform === 'android') { // 判断平台
		    var context = plus.android.importClass("android.content.Context");
		    var locationManager = plus.android.importClass("android.location.LocationManager");
		    var main = plus.android.runtimeMainActivity();
		    var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
		    if (!mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)) {
		      uni.showModal({
		        title: '提示',
		        content: '建议您开启定位权限，就能享受更多惊喜优惠',
		        showCancel: false, // 不显示取消按钮
		        success() {
		          if (!mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)) {
		            var Intent = plus.android.importClass('android.content.Intent');
		            var Settings = plus.android.importClass('android.provider.Settings');
		            var intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); 
		            main.startActivity(intent); // 打开系统设置GPS服务页面
		          } else {
		            console.log('GPS功能已开启');
		          }
		        }
		      });
		    }
		} else{
			var cllocationManger = plus.ios.importClass("CLLocationManager");    
			var enable = cllocationManger.locationServicesEnabled();    
			var status = cllocationManger.authorizationStatus();    
			if (enable && status != 2) {    
				//console.log("手机系统的定位已经打开");    
			} else {   
				//console.log("手机系统的定位没有打开");  
				//  定位没有开启时  提示用户是否开启  
				  plus.nativeUI.confirm("建议您开启定位权限，就能享受更多惊喜优惠", function(e) {    
						if (e.index == 1) {    
							var UIApplication = plus.ios.importClass("UIApplication");    
							var application2 = UIApplication.sharedApplication();    
							var NSURL2 = plus.ios.importClass("NSURL");                          
							  var setting2 = NSURL2.URLWithString("app-settings:"); // 打开应用权限  
							application2.openURL(setting2);    
							plus.ios.deleteObject(setting2);    
							plus.ios.deleteObject(NSURL2);    
							plus.ios.deleteObject(application2);    
						}    
					}, {    
						"buttons": ["不开启", "去设置"],    
						"verticalAlign": "center"    
					});    
			}    
			plus.ios.deleteObject(cllocationManger); 
		}
	},
	noticeIsOpen(){
		switch (system.platform){
		    //判断安卓是否开通应用通知权限
		    case 'android':
		      var  main = plus.android.runtimeMainActivity();
		      var  pkName = main.getPackageName();
		      var  NotificationManagerCompat = plus.android.importClass("android.support.v4.app.NotificationManagerCompat");  
		      var  packageNames = NotificationManagerCompat.from(main); 
		       //手机没有开启通知的权限
		      if (!packageNames.areNotificationsEnabled()) {
		        var  uid = main.getApplicationInfo().plusGetAttribute("uid");
		        var  Intent = plus.android.importClass('android.content.Intent');
		        var  Build = plus.android.importClass("android.os.Build");
		        uni.showModal({
		            title: '提示',
		            content: '检测到应用未开启通知权限，请开启通知权限',
		            success: function (res) {
		                if (res.confirm) {
		                    //android 8.0引导
		                    if (Build.VERSION.SDK_INT >= 26) {
		                        var  intent = new Intent('android.settings.APP_NOTIFICATION_SETTINGS');
		                    　　intent.putExtra('android.provider.extra.APP_PACKAGE', pkName);
		                    } else if (Build.VERSION.SDK_INT >= 21) { //android 5.0-7.0  
		                    　　var  intent = new Intent('android.settings.APP_NOTIFICATION_SETTINGS');
		                    　　intent.putExtra("app_package", pkName);
		                    　　intent.putExtra("app_uid", uid);
		                    } else { //(<21)其他--跳转到该应用管理的详情页
		                    　　var  Settings = plus.android.importClass("android.provider.Settings");
		                    　　var  Uri = plus.android.importClass("android.net.Uri");
		                    　　var  intent = new Intent();
		                    　　intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
		                    　　var  uri = Uri.fromParts("package", main.getPackageName(), null);
		                    　　intent.setData(uri);
		                    }
		                    // 跳转到该应用的系统通知设置页  
		                    main.startActivity(intent);
		                } else if (res.cancel) {
							//plus.runtime.quit();
		                    console.log('用户点击取消');
		                }
		            }
		        });
		      } 
		        
		      break;
		      //判断IOS是否开通应用通知权限
		    case 'ios':
		      // 识别IOS通知权限是否打开
		       var UIApplication = plus.ios.import("UIApplication");  
		      var app = UIApplication.sharedApplication();  
		      var enabledTypes = 0;  
		      if (app.currentUserNotificationSettings) {  
		          var settings = app.currentUserNotificationSettings();  
		          enabledTypes = settings.plusGetAttribute("types");  
		          if (enabledTypes == 0) {  
		              plus.nativeUI.confirm("推送设置没有开启，是否去开启？", function(e) {  
		                  if (e.index == 0) {  
		                      var NSURL2 = plus.ios.import("NSURL");  
		                      var setting2 = NSURL2.URLWithString("app-settings:");  
		                      var application2 = UIApplication.sharedApplication();  
		                      application2.openURL(setting2);  
		                      plus.ios.deleteObject(setting2);  
		                      plus.ios.deleteObject(NSURL2);  
		                      plus.ios.deleteObject(application2);  
		                  }  
		              }, {  
		                  "buttons": ["去开启", "暂不开启"],  
		                  "verticalAlign": "center"  
		              });  
		          }  
		          plus.ios.deleteObject(settings);  
		      } else {  
		          enabledTypes = app.enabledRemoteNotificationTypes();  
		          if(enabledTypes == 0){  
		              console.log("推送未开启!");  
		          }else{  
		              console.log("已经开启推送功能!")  
		          }  
		          console.log("enabledTypes2:" + enabledTypes);  
		      }  
		      plus.ios.deleteObject(app)
		    break;  
		    default:
		    break;
		}  
	},
	// 时间格式化date，separator(分割符)，format(yymmdd || yymmdd h:m:s)时间格式
	TimeFormatting(date,separator='-',format){
		let _date 
		if(date){
			_date = new Date(date)
		}
		_date = new Date()
		let y = _date.getFullYear()
		let mon = (_date.getMonth() + 1).toString().padStart(2, '0')
		let d = (_date.getDate()).toString().padStart(2, '0')
		let h = (_date.getHours()).toString().padStart(2, '0')
		let mm = (_date.getMinutes()).toString().padStart(2, '0')
		let s = (_date.getSeconds()).toString().padStart(2, '0')
		if(format === 'yymmdd'){
			return `${y}${separator}${mon}${separator}${d}`
		}else{
			return `${y}${separator}${mon}${separator}${d} ${h}:${mm}:${s}`
		}
	},
	/**验证手机和座机号是否正确**/
	Mobile_phone(parame){
		///^((0\d{2,3}-\d{7,8})|(1[358479]\d{9}))$/
		let isPhone = /^0\d{2,3}-?\d{7,8}$/;
		let isMob=/^1[3|5|8|9|7|4|6]\d{9}$/;
		if(isPhone.test(parame)||isMob.test(parame)){
			return true
		}else{
			return false
		}
		
	},
	
	/***验证邮箱*/
	checkEmail(parame){
		let Reg = /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/
		if(Reg.test(parame)){
			return true
		}else{
			return false
		}
	},
	
	/**匹配URL**/
	isUrl(str){
		if(str==null||str=="") return false;
		var result=str.match(/^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\’:+!]*([^<>\"])*$/);
		if(result==null)return false;
		return true;
	},
	
	/**匹配是否合法字符**/
	isRightfulString(str){
		if(str==null||str=="") return false;
		let result=str.match(/^[A-Za-z0-9_-]+$/);
		if(result==null)return false;
		return true;
	},
	
	/**匹配身份证号码**/
	isIdCardNo(num){
	　　 var len = num.length, re; 
	　　 if (len == 15) 
	　　 	re = new RegExp(/^(\d{6})()?(\d{2})(\d{2})(\d{2})(\d{2})(\w)$/); 
	　　 else if (len == 18) 
	　　 	re = new RegExp(/^(\d{6})()?(\d{4})(\d{2})(\d{2})(\d{3})(\w)$/); 
	　　 else {
			return {
				msg:"输入的数字位数不对",
				bool:false
			}
			
		} 
	　　 	var a = num.match(re); 
	　　 if (a != null) { 
		　　 if (len==15) 
		　　 	{ 
			　　 var D = new Date("19"+a[3]+"/"+a[4]+"/"+a[5]); 
			　　 var B = D.getYear()==a[3]&&(D.getMonth()+1)==a[4]&&D.getDate()==a[5]; 
		　　 } 
		　　 	else 
		　　 { 
			　　 var D = new Date(a[3]+"/"+a[4]+"/"+a[5]); 
			　　 var B = D.getFullYear()==a[3]&&(D.getMonth()+1)==a[4]&&D.getDate()==a[5]; 
		　　 } 
		　　 if (!B) {
				return {
					msg:"输入的身份证号 "+ a[0] +" 里出生日期不对。",
					bool:false
				}
				
				
			} 
	　　 } 
	　　 if(!re.test(num)){
				return {
					msg:"身份证最后一位只能是数字和字母。",
					bool:false
				}
		}
	　　  
	　　 return true; 
	},
	
	/**过滤中英文特殊字符，除英文"-_"字符外**/
	stringFilter(str){
		let pattern = new RegExp("[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~！@#￥%……&*（）——+|{}【】‘；：”“’。，、？]");
		let rs = "";
		for (let i = 0; i < str.length; i++) {
			rs = rs + str.substr(i, 1).replace(pattern, '');
		}
		return rs;
	},
	
	/**判断是否包含中英文特殊字符，除英文"-_"字符外**/
	isContainsSpecialChar(str){
		if(str==null||str=="") return false;
		let reg = RegExp(/[(\ )(\`)(\~)(\!)(\@)(\#)(\$)(\%)(\^)(\&)(\*)(\()(\))(\+)(\=)(\|)(\{)(\})(\')(\:)(\;)(\')(',)(\[)(\])(\.)(\<)(\>)(\/)(\?)(\~)(\！)(\@)(\#)(\￥)(\%)(\…)(\&)(\*)(\（)(\）)(\—)(\+)(\|)(\{)(\})(\【)(\】)(\‘)(\；)(\：)(\”)(\“)(\’)(\。)(\，)(\、)(\？)]+/);   
		 return reg.test(str);
	},
	
	/**判断小数位数**/
	decimal(number){
		let res = /^[0-9]+([.][0-9]{1}){0,1}$/
		if(!res.test(number)){
			return false
		}else{
			return true
		}
	}
	
}

// 对Date的扩展，将 Date 转化为指定格式的String
// 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符，
// 年(y)可以用 1-4 个占位符，毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
// 例子：
// (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
// (new Date()).Format("yyyy-M-d h:m:s.S")      ==> 2006-7-2 8:9:4.18
Date.prototype.Format = function(fmt) { //author: meizz
	fmt = fmt || 'yyyy-MM-dd hh:mm:ss.S';
	var o = {
		"M+": this.getMonth() + 1, //月份
		"d+": this.getDate(), //日
		"h+": this.getHours(), //小时
		"m+": this.getMinutes(), //分
		"s+": this.getSeconds(), //秒
		"q+": Math.floor((this.getMonth() + 3) / 3), //季度
		"S": this.getMilliseconds() //毫秒
	};
	if (/(y+)/.test(fmt))
		fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
	for (var k in o)
		if (new RegExp("(" + k + ")").test(fmt))
			fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
	return fmt;
}
